package com.symc.his.api.impl.employee;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.symc.his.api.base.BaseApiService;
import com.symc.his.api.base.BaseResponse;
import com.symc.his.api.employee.EmployeeService;
import com.symc.his.api.employee.dto.req.DepartmentReqDTO;
import com.symc.his.api.employee.dto.resp.DepartmentRespDTO;
import com.symc.his.api.employee.dto.resp.EmployeeRespDTO;
import com.symc.his.api.impl.entity.DepartmentDO;
import com.symc.his.api.impl.entity.EmployeeDO;
import com.symc.his.api.impl.mapper.DepartmentMapper;
import com.symc.his.api.impl.mapper.EmployeeMapper;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 科室员工管理服务接口实现
 * @CreateTime: 2023/3/6 21:03
 * @Version:
 * @Since: 1.8
 * @Author: 辛凤文 forward.seen@foxmail.com
 */
@RestController
public class EmployeeServiceImpl extends BaseApiService implements EmployeeService {

    @Resource
    private DepartmentMapper departmentMapper;

    @Resource
    private EmployeeMapper employeeMapper;

    @Override public String testEmployeeService() {
        return "testEmployeeService : 111111";
    }

    @Override public BaseResponse<DepartmentRespDTO> getDepartment(DepartmentReqDTO departmentReqDTO) {
        DepartmentDO departmentReq = DTO2DO(departmentReqDTO, DepartmentDO.class);
        DepartmentDO department = departmentMapper.selectOne(new QueryWrapper(departmentReq));
        return setResultSuccess(department);
    }

    @Override public BaseResponse<EmployeeRespDTO> getDoctorListByDept(String deptCode) {
        LambdaQueryWrapper<EmployeeDO> queryWrapper = new LambdaQueryWrapper<EmployeeDO>()
            .eq(EmployeeDO::getBusinessDeptCode, deptCode)
            .eq(EmployeeDO::getEmplClass, "01");
        List<EmployeeDO> doctors = employeeMapper.selectList(queryWrapper);
        return setResultSuccess(doctors);
    }

}